#include "common.hpp"

namespace component {

Expression::Expression() { exp_ = RoboExpression::kOTHER_ERROR; }

Expression::Expression(RoboExpression exp) : exp_(exp) {}

Expression& Expression::operator=(RoboExpression exp) {
  exp_ = exp;
  return *this;
}

Expression& Expression::operator()(RoboExpression exp) {
  exp_ = exp;
  return *this;
}

bool Expression::operator==(RoboExpression exp) { return exp_ == exp; }

std::string Expression::What() {
  switch (exp_) {
    case RoboExpression::kOK:
      return std::string("ok");
    case RoboExpression::kFILE_ERROR:
      return std::string("File path error");
    case RoboExpression::kFRAME_ERROR:
      return std::string("Frame is empty");
    case RoboExpression::kTRANS_ERROR:
      return std::string("Transport to MCU / PC error");
    case RoboExpression::kRECV_ERROR:
      return std::string("Receive from MCU / PC error");
    default:
      return std::string("Other error occurs");
  }
}

#ifdef __cplusplus

std::string NmeaTypeToString(NmeaType type) {
  switch (type) {
    case NmeaType::kGGA:
      return std::string("GGA");
    case NmeaType::kRMC:
      return std::string("RMC");
    case NmeaType::kTXT:
      return std::string("TXT");
    default:
      return std::string("Unknown");
  }
}

#endif
}  // namespace component